home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD59615212000.psc / Mixed API Demo / modMsgBoxAPI.bas < prev    next >
Encoding:
BASIC Source File  |  2000-05-17  |  5.8 KB  |  132 lines

  1. Attribute VB_Name = "modMsgBoxAPI"
  2. '/\/\/\/\/\/\/\ API MESSAGE BOX RE-USABLE MODULE /\/\/\/\/\
  3. 'Code by Andy McCurtin
  4. 'Do what you want with it
  5. 'And ENJOY!!!!
  6. 'Any probs e-mail
  7. 'andy_mccurtin@yahoo.com
  8.  
  9. '/\/\/\/\/\/\ BEFORE YOU READ ANY FURTHER!!! /\/\/\/\/\/\/\
  10. '/\/\ Examples of how to use this Module are at the bottom
  11. '/\/\ of the code, and included on the form.
  12. '##########################################################
  13. '# For anyone who isn't sure how the API declare works    #
  14. '# itworks like this :-                                   #
  15. '#                                                        #
  16. '# [Public/Private] Declare Sub/Function name Lib _       #
  17. '# "DLL name" [Alias "Alias name"] [(Argument List)] _    #
  18. '# [As Type]                                              #
  19. '#                                                        #
  20. '# You don't need the underscore's(_) but they help make  #
  21. '# your code easier to read.                              #
  22. '#                                                        #
  23. '# The stuff in the square brackets([ ]) is optional, the #
  24. '# Slash (/) means that you choose one or the other.      #
  25. '# The Argument List is list of arguments that may or may #
  26. '# not be present.                                        #
  27. '##########################################################
  28.  
  29. Option Explicit
  30.  
  31. '//This is the MessageBox API call
  32. Public Declare Function MessageBox Lib "user32" Alias _
  33. "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As _
  34. String, ByVal lpCaption As String, ByVal wType As Long) _
  35. As Long
  36. '##########################################################
  37. '# The above breaks down like this :-                     #
  38. '#                                                        #
  39. '# hwnd = This is the handle to a window                  #
  40. '#                                                        #
  41. '# lpText = This is the message that appears in the       #
  42. '#          MessageBox                                    #
  43. '#                                                        #
  44. '# lpCaption = The title of the MessageBox                #
  45. '#                                                        #
  46. '# wType = This is a number that represents the style of  #
  47. '#         the MessageBox i.e. Icon or Buttons etc.       #
  48. '##########################################################
  49.  
  50.  
  51.  
  52. '//These are the constants for the MessageBox buttons.
  53. Public Const MB_OK = &H0&
  54. Public Const MB_OKCANCEL = &H1&
  55. Public Const MB_ABORTRETRYIGNORE = &H2&
  56. Public Const MB_YESNOCANCEL = &H3&
  57. Public Const MB_YESNO = &H4&
  58. Public Const MB_RETRYCANCEL = &H5&
  59.  
  60.  
  61. '//These are the constants for the MessageBox Icon.
  62. Public Const MB_ICONMASK = &HF0&
  63. Public Const MB_ICONCRITICAL = &H10&
  64. Public Const MB_ICONQUESTION = &H20&
  65. Public Const MB_ICONINFORMATION = &H40&
  66. Public Const MB_ICONEXCLAMATION = &H30&
  67.  
  68.  
  69. '//These are the constants for the MessageBox Modal (This
  70. '//basically means the MessageBox gets the users attention.
  71. '//How much attention is up to you, SYSTEMMODAL means that
  72. '//the MessageBox stays visible until closed, above ALL other
  73. '//applications.
  74. '//TASKMODAL means that the program cannot continue however
  75. '//the MessageBox will only be on top of the program not the
  76. '//whole system as with SYSTEMMODAL (try them out to see the
  77. '//difference firsthand).
  78. Public Const MB_SYSTEMMODAL = &H1000&
  79. Public Const MB_TASKMODAL = &H2000&
  80.  
  81.  
  82. '//The Function(MessageBox) returns a number(Long) these are the
  83. '//constants.
  84. Public Const IDOK = 1
  85. Public Const IDCANCEL = 2
  86. Public Const IDABORT = 3
  87. Public Const IDRETRY = 4
  88. Public Const IDIGNORE = 5
  89. Public Const IDYES = 6
  90. Public Const IDNO = 7
  91.  
  92.  
  93. 'Using this COOL mosule
  94. '----------------------
  95. '##########################################################
  96. '# To call this Function use the following :-             #
  97. '# Call MessageBox(Form1.hwnd, "This is my MessageBox", _ #
  98. '#  "This is a Test", MB_ICONQUESTION)                    #
  99. '#                                                        #
  100. '#                          OR                            #
  101. '#                                                        #
  102. '# Call MessageBox(Form1.hwnd, "This is my MessageBox", _ #
  103. '#  "This is a Test", MB_OKCANCEL Or MB_ICONQUESTION )    #
  104. '#                                                        #
  105. '#                          OR                            #
  106. '#                                                        #
  107. '# Call MessageBox(Form1.hwnd, "This is my MessageBox", _ #
  108. '#  "This is a Test", MB_OKCANCEL Or MB_ICONQUESTION _    #
  109. '#  or MB_TASKMODAL)                                      #
  110. '#                                                        #
  111. '# I don't know why the API uses Or instead of the more   #
  112. '# logical And, but it does.                              #
  113. '#                                                        #
  114. '# Again the underscore's(_) are not essential but make   #
  115. '# the code more readable.                                #
  116. '#                                                        #
  117. '#         -------------------------------------          #
  118. '#                                                        #
  119. '# To respond to a response from the user use this :-     #
  120. '#                                                        #
  121. '# If MessageBox(Form1.hwnd, "Do you like this?", _       #
  122. '#  "This is a Test", MB_YESNO Or MB_ICONQUESTION ) = _   #
  123. '#   IDYES Then                                           #
  124. '#      Call MessageBox(Form1.hwnd, "Thank you","Great" _ #
  125. '#      MB_OK Or MB_ICONQUESTION )                        #
  126. '# End IF                                                 #
  127. '#                                                        #
  128. '# You could also use a Case statment(shown on frmTest    #
  129. '# that would be better if you have a few responses.      #
  130. '##########################################################
  131.  
  132.